package com.zhuss.order.processor;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import com.zhuss.bean.bo.order.order.CreatePrepayBo;
import com.zhuss.common.AbstractProcessor;
import com.zhuss.common.Processor;
import com.zhuss.exception.DzcxException;
import com.zhuss.order.db.dao.ext.PrepayDao;
import com.zhuss.order.db.entity.Prepay;


/**
 * @description: 预支付创建
 * @author: zhushanshuo
 * @create: Tue Jan 12 18:10:03 CST 2021
 **/
@Component("prepayCreate")
public class PrepayCreate extends AbstractProcessor<Object, CreatePrepayBo> implements Processor<Object, CreatePrepayBo> {

    @Autowired
    private PrepayDao prepayDao;
    
    @Autowired
	@Qualifier("prepayRead")
	private PrepayRead prepayRead;
    
    
    /**
     * 校验
     */
    @Override
    public void check(CreatePrepayBo bo) throws DzcxException {
    }
    
    /**
     * 操作方法
     */
    @Override
    public Object process(CreatePrepayBo param) {
    	Prepay record = new Prepay();
    	record.setOrderId(param.getOrderId());
    	record.setAppId(param.getAppId());
    	record.setMchId(param.getMchId());
    	record.setTradeType(param.getTradeType());
    	record.setNonceStr(param.getNonceStr());
    	record.setBody(param.getBody());
    	record.setWxPackage(param.getWxPackage());
    	record.setSign(param.getSign());
    	record.setReturnMsg(param.getReturnMsg());
    	record.setResultCode(param.getResultCode());
    	record.setReturnCode(param.getReturnCode());
    	record.setWxPrepayId(param.getWxPrepayId());
    	record.setTime(param.getTime());
    	record.setTotalPrice(param.getTotalPrice());
    	record.setStatus(param.getStatus());

    	
    	record.setCreatorId(param.getConcurrentUserId());
    	record.setCreator(param.getConcurrentUserName());
    	record.setCreateTime(new Date());
    	prepayDao.create(record);
    	param.setTargetId(record.getPrepayId());
        return null;
    }
    
    /**
     * 操作日志
     */
	@Override
	public Object log(CreatePrepayBo param) throws DzcxException {
    	return null;
	}
}
